from watchdog.observers import Observer
from watchdog.events import *
import os

config = {
    'watch': r".\src_dir", 
    'dst': r".\dst_dir",
}

dir = config.get('watch')
print(dir)

class MyHandler(FileSystemEventHandler):
    def on_modified(self, event):
        print('file modified %s' % event.src_path)
        os.system("copy %s %s" % (event.src_path, config.get('dst')))
    
    def on_created(self, event):
        print('file created %s' % event.src_path)
        os.system("copy %s %s" % (event.src_path, config.get('dst')))
    
if __name__ == '__main__':
    event_handler = MyHandler()
    observer = Observer()
    observer.schedule(event_handler, dir, recursive=True)
    observer.start()
    try:
        while True:
            pass
    except KeyboardInterrupt:
        observer.stop()
    observer.join()